<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('admins', function (Blueprint $table) {
            $table->comment('管理员表');
            $table->increments('id');
            $table->tinyInteger('status')->default(1)->comment('状态：1正常,2禁用');
            $table->string('nickname')->nullable()->comment('昵称');
            $table->string('avatar')->nullable()->comment('头像');
            $table->string('username')->unique();
            $table->string('password');
            $table->string('email')->nullable()->unique();
            $table->string('phone')->nullable()->unique()->comment('手机号');
            $table->ipAddress('register_ip')->nullable()->comment('注册ip');
            $table->ipAddress('login_ip')->nullable()->comment('登录ip');
            $table->timestamp('login_time')->nullable()->comment('上次登录时间');
            $table->unsignedInteger('failed_attempts')->default(0)->comment('登录失败次数');
            $table->timestamp('lockout_until')->nullable()->comment('账号锁定截止时间');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('admins');
    }
};
